package com;

import com.zz.mapper.BookMapper;
import com.zz.mapper.StudentMapper;
import com.zz.model.Book;
import com.zz.model.Student;
import com.zz.mybatis.MybatisUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/1/11.
 */
public class Demo {
    @Test
    public void book() {
        SqlSession s = MybatisUtil.getSession();
        BookMapper bm = s.getMapper(BookMapper.class);
        Book b = new Book();
        //b.setName("java从土门到精通");
        //b.setPrice(1);
        //bm.insert(b);
        //List<Book> lb = bm.query();
        //List<Book> lb = bm.sshh();
        //System.out.println(lb.size());
        //for (Book b : lb) {
        //    System.out.println(b.getName()+"-------");
        //}
        //b.setName("加瓦基础啊");
        //b.setPrice(25);
        //System.out.println(bm.save("html5", 45));
        //System.out.println(bm.deletee(8));
        //System.out.println(bm.update(2, "php从入门到放弃", 77));
/*
        b.setId(9);
        b.setName("js从入门到放弃");
        b.setPrice(-99);
        System.out.println(bm.myupdate(b));
*/
        //List<Book> lll = bm.page(2, 6);
        //System.out.println(lll.size());


        /*Map<String, Integer> m = new HashMap<String, Integer>();
        m.put("mys", 0);
        bm.selCount(m);
        System.out.println(m.get("mys"));*/
        s.commit();
        s.close();
    }

    @Test
    public void sss() {
        SqlSession s = MybatisUtil.getSession();
        StudentMapper sm = s.getMapper(StudentMapper.class);
        //Student stu = new Student();
        //stu.setName("jerry");
        //stu.setAddress("英国");
        //sm.save(stu);
        List<Student> ls = sm.query();
        for (Student stu : ls) {
            System.out.println(stu.getName());
        }
        s.commit();
        s.close();
    }
}
